/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.slayer.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.slayer.model.BMSBorrowing;
import com.slayer.model.BMSBorrowingModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the BMSBorrowing service. Represents a row in the &quot;BMS_BMSBorrowing&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.slayer.model.BMSBorrowingModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BMSBorrowingImpl}.
 * </p>
 *
 * @author Hemant
 * @see BMSBorrowingImpl
 * @see com.slayer.model.BMSBorrowing
 * @see com.slayer.model.BMSBorrowingModel
 * @generated
 */
public class BMSBorrowingModelImpl extends BaseModelImpl<BMSBorrowing>
	implements BMSBorrowingModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a b m s borrowing model instance should use the {@link com.slayer.model.BMSBorrowing} interface instead.
	 */
	public static final String TABLE_NAME = "BMS_BMSBorrowing";
	public static final Object[][] TABLE_COLUMNS = {
			{ "borrowingId", Types.BIGINT },
			{ "bookId", Types.BIGINT },
			{ "memberId", Types.BIGINT },
			{ "dateBorrowed", Types.TIMESTAMP },
			{ "dateReturned", Types.TIMESTAMP }
		};
	public static final String TABLE_SQL_CREATE = "create table BMS_BMSBorrowing (borrowingId LONG not null primary key,bookId LONG,memberId LONG,dateBorrowed DATE null,dateReturned DATE null)";
	public static final String TABLE_SQL_DROP = "drop table BMS_BMSBorrowing";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.slayer.model.BMSBorrowing"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.slayer.model.BMSBorrowing"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.slayer.model.BMSBorrowing"));

	public BMSBorrowingModelImpl() {
	}

	public long getPrimaryKey() {
		return _borrowingId;
	}

	public void setPrimaryKey(long primaryKey) {
		setBorrowingId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_borrowingId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return BMSBorrowing.class;
	}

	public String getModelClassName() {
		return BMSBorrowing.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("borrowingId", getBorrowingId());
		attributes.put("bookId", getBookId());
		attributes.put("memberId", getMemberId());
		attributes.put("dateBorrowed", getDateBorrowed());
		attributes.put("dateReturned", getDateReturned());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long borrowingId = (Long)attributes.get("borrowingId");

		if (borrowingId != null) {
			setBorrowingId(borrowingId);
		}

		Long bookId = (Long)attributes.get("bookId");

		if (bookId != null) {
			setBookId(bookId);
		}

		Long memberId = (Long)attributes.get("memberId");

		if (memberId != null) {
			setMemberId(memberId);
		}

		Date dateBorrowed = (Date)attributes.get("dateBorrowed");

		if (dateBorrowed != null) {
			setDateBorrowed(dateBorrowed);
		}

		Date dateReturned = (Date)attributes.get("dateReturned");

		if (dateReturned != null) {
			setDateReturned(dateReturned);
		}
	}

	public long getBorrowingId() {
		return _borrowingId;
	}

	public void setBorrowingId(long borrowingId) {
		_borrowingId = borrowingId;
	}

	public long getBookId() {
		return _bookId;
	}

	public void setBookId(long bookId) {
		_bookId = bookId;
	}

	public long getMemberId() {
		return _memberId;
	}

	public void setMemberId(long memberId) {
		_memberId = memberId;
	}

	public Date getDateBorrowed() {
		return _dateBorrowed;
	}

	public void setDateBorrowed(Date dateBorrowed) {
		_dateBorrowed = dateBorrowed;
	}

	public Date getDateReturned() {
		return _dateReturned;
	}

	public void setDateReturned(Date dateReturned) {
		_dateReturned = dateReturned;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			BMSBorrowing.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public BMSBorrowing toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (BMSBorrowing)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		BMSBorrowingImpl bmsBorrowingImpl = new BMSBorrowingImpl();

		bmsBorrowingImpl.setBorrowingId(getBorrowingId());
		bmsBorrowingImpl.setBookId(getBookId());
		bmsBorrowingImpl.setMemberId(getMemberId());
		bmsBorrowingImpl.setDateBorrowed(getDateBorrowed());
		bmsBorrowingImpl.setDateReturned(getDateReturned());

		bmsBorrowingImpl.resetOriginalValues();

		return bmsBorrowingImpl;
	}

	public int compareTo(BMSBorrowing bmsBorrowing) {
		long primaryKey = bmsBorrowing.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		BMSBorrowing bmsBorrowing = null;

		try {
			bmsBorrowing = (BMSBorrowing)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = bmsBorrowing.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<BMSBorrowing> toCacheModel() {
		BMSBorrowingCacheModel bmsBorrowingCacheModel = new BMSBorrowingCacheModel();

		bmsBorrowingCacheModel.borrowingId = getBorrowingId();

		bmsBorrowingCacheModel.bookId = getBookId();

		bmsBorrowingCacheModel.memberId = getMemberId();

		Date dateBorrowed = getDateBorrowed();

		if (dateBorrowed != null) {
			bmsBorrowingCacheModel.dateBorrowed = dateBorrowed.getTime();
		}
		else {
			bmsBorrowingCacheModel.dateBorrowed = Long.MIN_VALUE;
		}

		Date dateReturned = getDateReturned();

		if (dateReturned != null) {
			bmsBorrowingCacheModel.dateReturned = dateReturned.getTime();
		}
		else {
			bmsBorrowingCacheModel.dateReturned = Long.MIN_VALUE;
		}

		return bmsBorrowingCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(11);

		sb.append("{borrowingId=");
		sb.append(getBorrowingId());
		sb.append(", bookId=");
		sb.append(getBookId());
		sb.append(", memberId=");
		sb.append(getMemberId());
		sb.append(", dateBorrowed=");
		sb.append(getDateBorrowed());
		sb.append(", dateReturned=");
		sb.append(getDateReturned());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(19);

		sb.append("<model><model-name>");
		sb.append("com.slayer.model.BMSBorrowing");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>borrowingId</column-name><column-value><![CDATA[");
		sb.append(getBorrowingId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>bookId</column-name><column-value><![CDATA[");
		sb.append(getBookId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>memberId</column-name><column-value><![CDATA[");
		sb.append(getMemberId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>dateBorrowed</column-name><column-value><![CDATA[");
		sb.append(getDateBorrowed());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>dateReturned</column-name><column-value><![CDATA[");
		sb.append(getDateReturned());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = BMSBorrowing.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			BMSBorrowing.class
		};
	private long _borrowingId;
	private long _bookId;
	private long _memberId;
	private Date _dateBorrowed;
	private Date _dateReturned;
	private BMSBorrowing _escapedModelProxy;
}